<?php

/**
 * Description of PersonPersonClass
 *
 * @author adhamhelal
 */
class PersonPersonPanel extends Qpanel {
    protected $mctPerson;

    //Controls
    protected $txtFirstName;
    protected $txtLastName;
    protected $calDob;
    protected $strTemplate;

    public function __construct($objParentObject, $mctPerson, $strControlId = null) {
        // Call the Parent
        try {
            parent::__construct($objParentObject, $strControlId);
        } catch (QCallerException $objExc) {
            $objExc->IncrementOffset();
            throw $objExc;
        }

        // Setup Template
        $this->strTemplate = __DOCROOT__.__PERSON__ .  '/tpl/qpanel.tpl.php';
        // Set the Person Meta Conrol
        $this->mctPerson = $mctPerson;
        // Call MetaControl's methods to create qcontrols based on ComSchool's data fields
        $this->txtFirstName = $this->mctPerson->txtFirstName_Create();
        $this->txtFirstName->SetParentControl($this);
        $this->txtLastName = $this->mctPerson->txtLastName_Create();
        $this->txtLastName->SetParentControl($this);
        $this->calDob =$this->mctPerson->calDob_Create() ;
        $this->calDob->SetParentControl($this);
    }

    public function Validate() {
        $Error = false;
        if ($this->txtFirstName->Text == "") {
            $this->txtFirstName->Warning="Could Not be Empty";
            $Error=true;
        }
        $blnFocused = false;
        foreach ($this->GetChildControls()  as $objControl) {
            if ( !is_null($objControl->Warning) ) {
                if (!$blnFocused) {
                    $objControl->Focus();
                    $blnFocused = true;
                }
                $objControl->Blink();
            }
        }

        return $Error;
    }




}
?>

